
const pageHelper = require('../../../../../helper/page_helper.js');
const ProjectBiz = require('../../../biz/project_biz.js');
const CateBiz = require('../../../biz/cate_biz.js')


Page({
	data: {
		isLoad: false,
		query: '',
		productList: [
			{
				id: 1,
				name: '矿用隔爆兼本质安全型移动变电站',
				image: '/projects/prod/images/products/sensor.jpg',
				category: '移变',
				description: '真空开关、移动变电站用低压保护箱'
			},
			{
				id: 2,
				name: '高压组合真空配电装置',
				image: '/projects/prod/images/products/control.jpg',
				category: '组合高防',
				description: '矿用隔爆兼本质安全型高压组合真空配电装置'
			},
			{
				id: 3,
				name: '煤矿供电监控系统',
				image: '/projects/prod/images/products/data.jpg',
				category: '供电系统',
				description: '矿用供电监控scada系统'
			},
			{
				id: 4,
				name: '组合馈电',
				image: '/projects/prod/images/products/display.jpg',
				category: '组合馈电',
				description: '组合馈电'
			},
			{
				id: 5,
				name: '组合开关',
				image: '/projects/prod/images/products/power.jpg',
				category: '组合开关',
				description: '组合开关'
			},
			{
				id: 6,
				name: '管控平台看板',
				image: '/projects/prod/images/products/comm.jpg',
				category: '大数据看板',
				description: '管控平台看板'
			}
		]
	},

	onLoad: async function (options) {
		ProjectBiz.initPage(this);

		this._loadDetail();

	},

	_loadDetail: async function (e) {
		let cateList = await CateBiz.getAllCateOptions();
		this.setData({
			isLoad: true,
			cateList
		});
	},

	// 产品点击事件
	onProductTap: function (e) {
		const id = e.currentTarget.dataset.id;
		wx.navigateTo({
			url: `../detail/product_detail?id=${id}`
		});
	},

	// 搜索功能
	onSearch: function (e) {
		const keyword = e.detail.value;
		this.setData({
			query: keyword
		});
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () { },

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: async function () {
	},

	onPullDownRefresh: async function () {
		await this._loadDetail();
		wx.stopPullDownRefresh();
	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {

	},

	url: async function (e) {
		pageHelper.url(e, this);
	},


	bindSearchConfirm: function (e) {
		ProjectBiz.bindSearchConfirm(this);
	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function () {

	}, 

})